<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">

    <h:body>
        <ui:composition template="templateGeneral.xhtml">
            <ui:define name="title">Zaposleni</ui:define>
            <ui:define name="center">

                <h:form id="forma" enctype="multipart/form-data">

                    <p:growl id="zapCtrlMessage" sticky="false" />
                    
                    <h:panelGrid columns="1" cellpadding="10" style="margin-left: 300px">
                    <h:outputText value="Odaberite predmet cije podatke zelite da izmenite" style="font-weight: bolder"/>
                            <p:selectOneMenu value="#{zapCtrl.selected}" filter="true" filterMatchMode="contains">
                                <p:ajax listener="#{zapCtrl.onChange()}" update=":forma:predmetiZaposleni"/>
                                <f:selectItem itemLabel="Odaberi predmet" itemValue=""/>
                                <f:selectItems value="#{zapCtrl.predmetList}"/>
                            </p:selectOneMenu>
                        </h:panelGrid>

                    <p:tabView id="predmetiZaposleni"  orientation="left" effect="fold" rendered="true" style="padding-top:40px">
                        
                         

                        <p:tab title="O predmetu">                            
                            <h:panelGrid columns="2" cellpadding="10">  
                                <h:outputText value="Sifra:" style="font-weight: bold"/>
                                <p:inplace>
                                    <p:inputText value="#{zapCtrl.predmet.sifra}"/>
                                </p:inplace>
                                <h:outputText value="Tip:" style="font-weight: bold"/>
                                <p:inplace>
                                    <p:inputText value="#{zapCtrl.predmet.tip}"/>
                                </p:inplace >
                                <h:outputText value="ESPB:" style="font-weight: bold"/>
                                <p:inplace>
                                    <p:inputText value="#{zapCtrl.predmet.espb}"/>
                                </p:inplace>
                                <h:outputText value="Semestar:" style="font-weight: bold"/>
                                <p:inplace>
                                    <p:inputText value="#{zapCtrl.predmet.semestar}"/>
                                </p:inplace>
                                <h:outputText value="Fond casova:" style="font-weight: bold"/>
                                <p:inplace>
                                    <p:inputText value="#{zapCtrl.predmet.fondCasova}"/>
                                </p:inplace>
                                <h:outputText value="Laboratorija:" style="font-weight: bold"/>
                                <p:inplace>
                                    <p:inputText value="#{zapCtrl.predmet.lab}"/>
                                </p:inplace>
                                <h:outputText value="Propozicije:" style="font-weight: bold"/>
                                <p:inplace>
                                    <p:inputTextarea value="#{zapCtrl.predmet.propozicije}"/>                       
                                </p:inplace> 
                                <h:outputText value="Cilj" style="font-weight: bold"/>
                                <p:inplace>
                                    <p:editor value="#{zapCtrl.predmet.cilj}"/>                       
                                </p:inplace>
                                
                                <h:commandButton value="Snimi" actionListener="#{zapCtrl.snimiPromene}"/>
                            </h:panelGrid>  

                        </p:tab>
                        <p:tab title="Materijali">
                            <p:fieldset legend="Dodaj" toggleable="true" toggleSpeed="500" collapsed="true">
                                <h:panelGrid columns="1" cellspacing="10">
                                    <p:selectOneMenu value="#{zapCtrl.typeToAdd}" style="min-width: 80px">
                                         <f:selectItem itemLabel="Odaberi" itemValue=""/>
                                        <f:selectItem itemLabel="Predavanja" itemValue="1"/>
                                        <f:selectItem itemLabel="Vezbe" itemValue="2"/>
                                    </p:selectOneMenu> 
                                    <h:panelGrid columns="2" cellspacing="10">
                                        <h:outputText value="Opis" style="font-weight: bold"/>
                                        <p:inputText value="#{zapCtrl.noviMaterijal.opis}"/>    
                                    </h:panelGrid>
                                    <p:fileUpload mode="advanced" fileUploadListener="#{zapCtrl.uploadHandler}" />
                                    <p:commandButton value="Snimi" actionListener="#{zapCtrl.snimiMaterijal}" ajax="false"/>
                                </h:panelGrid>
                            </p:fieldset>
                            <p:accordionPanel multiple="true" >
                                <p:tab title="Predavanja"  >
                                    <c:forEach items="#{zapCtrl.predavanja}" var="pred">
                                        <h:panelGrid columns="7" cellpadding="10">
                                            <h:outputText value="#{pred.opis}"/>
                                            <h:outputText value="#{pred.fajlovi.tip}"/>
                                            <h:outputText value="#{pred.fajlovi.velicina}KB"/>
                                            <h:outputText value="#{pred.fajlovi.datum}"/>
                                            <h:outputText value="#{pred.zaposleni.korisnik.ime}"/>
                                            <h:outputText value="Fajl"/>
                                            <p:commandButton icon="ui-icon-circle-close" actionListener="#{zapCtrl.obrisiPredavanje(pred)}"/>
                                        </h:panelGrid>
                                    </c:forEach>
                                </p:tab>

                                <p:tab title="Vezbe">
                                    <c:forEach items="#{zapCtrl.vezbe}" var="vezba">
                                        <h:panelGrid columns="7" cellpadding="10">
                                            <h:outputText value="#{vezba.opis}"/>
                                            <h:outputText value="#{vezba.fajlovi.tip}"/>
                                            <h:outputText value="#{vezba.fajlovi.velicina}KB"/>
                                            <h:outputText value="#{vezba.fajlovi.datum}"/>
                                            <h:outputText value="#{vezba.zaposleni.korisnik.ime}"/>
                                            <h:outputText value="Fajl"/>
                                            <p:commandButton icon="ui-icon-circle-close" actionListener="#{zapCtrl.obrisiVezbu(vezba,vezba.fajlovi)}"/>
                                        </h:panelGrid>
                                    </c:forEach>
                                </p:tab>
                            </p:accordionPanel>

                        </p:tab>

                        <p:tab title="Ispitni zadaci">
                            <p:fieldset legend="Dodaj rok" toggleable="true" toggleSpeed="500" collapsed="true">
                                <h:panelGrid columns="1" cellpadding="10">  
                                    <h:panelGrid columns="2" cellspacing="10">
                                        <h:outputText value="Opis" style="font-weight: bold"/>
                                        <p:inputText value="#{zapCtrl.noviRok.opis}" />
                                    </h:panelGrid>
                                    <p:fileUpload  mode="advanced" fileUploadListener="#{zapCtrl.uploadHandler}"/>
                                    <p:commandButton value="Snimi" actionListener="#{zapCtrl.snimiRok}" ajax="false"/>
                                </h:panelGrid>
                            </p:fieldset>
                            <h:panelGrid columns="6" cellpadding="10">
                                <c:forEach items="#{zapCtrl.rokovi}" var="rok">                                    
                                    <h:outputText value="#{rok.opis}"/>
                                    <h:outputText value="#{rok.fajlovi.tip}"/>
                                    <h:outputText value="#{rok.fajlovi.velicina}KB"/>
                                    <h:outputText value="#{rok.datum}"/>
                                    <p:commandButton icon="ui-icon-circle-close" actionListener="#{zapCtrl.obrisiRok(rok,rok.fajlovi)}" />
                                </c:forEach>
                            </h:panelGrid>
                        </p:tab>

                        <p:tab  title="Labaroratorija">
                            <p:selectOneMenu value="#{zapCtrl.selectedLabVezba}" filter="true" filterMatchMode="contains" >
                                <p:ajax listener="#{zapCtrl.onChangeLabVezba}" update=":forma:predmetiZaposleni:labID"/>
                                <f:selectItem itemLabel="Odaberi  " itemValue=""/>
                                <f:selectItems value="#{zapCtrl.labVezbe}"/>
                            </p:selectOneMenu>
                            <h:panelGrid id="labID" columns="1" cellpadding="10" >
                                
                                <p:inputText value="#{zapCtrl.labVezba.naziv}" style="min-width: 300px; font-weight: bold"/>
                                <p:editor value="#{zapCtrl.labVezba.propozicije}" style="font-weight: normal"/>
                                <c:forEach items="#{zapCtrl.fajloviLabVezba}" var="labVzbFajl">  
                                    <h:panelGrid columns="4" cellspacing="10">
                                    <h:outputText value="#{labVzbFajl.naziv}"/>
                                    <h:outputText value="#{labVzbFajl.velicina}KB"/>
                                    <h:outputText value="#{labVzbFajl.datum}"/>
                                    <p:commandButton icon="ui-icon-circle-close" actionListener="#{zapCtrl.obrisiLabVezbaFile(labVzbFajl)}"/>
                                    </h:panelGrid>
                                </c:forEach>
                                <p:fileUpload fileUploadListener="#{zapCtrl.labVezbaUploadHandler}" mode="advanced" rendered="#{zapCtrl.hasLabVezba}" />
                                <p:commandButton value="Snimi" actionListener="#{zapCtrl.snimiLabVezbu}" ajax="false" rendered="#{zapCtrl.hasLabVezba}"/>

                            </h:panelGrid>
                        </p:tab>

                        <p:tab id="projID" title="Projekat">
                            <p:selectOneMenu value="#{zapCtrl.selectedDomaci}" filter="true" filterMatchMode="contains" >
                                <p:ajax listener="#{zapCtrl.onChangeDomaci}" update=":forma:predmetiZaposleni:projID"/>
                                <f:selectItem itemLabel="Odaberi  " itemValue=""/>
                                <f:selectItems value="#{zapCtrl.domaciList}"/>
                            </p:selectOneMenu>
                            <h:panelGrid  columns="1" cellpadding="10">
                                <p:inputText value="#{zapCtrl.domaci.naziv}" style="font-weight: bold"/>
                                <p:editor value="#{zapCtrl.domaci.opis}" style="font-weight: normal"/>
                                <c:forEach items="#{zapCtrl.fajloviDomaci}" var="domFajl">  
                                    <h:panelGrid columns="4" cellspacing="10">
                                    <h:outputText value="#{domFajl.naziv}"/>                                   
                                    <h:outputText value="#{domFajl.velicina}KB"/>
                                    <h:outputText value="#{domFajl.datum}"/>
                                    <p:commandButton icon="ui-icon-circle-close" actionListener="#{zapCtrl.obrisiDomaciFile(domFajl)}"/>
                                    </h:panelGrid>
                                </c:forEach>       
                                <p:fileUpload fileUploadListener="#{zapCtrl.domaciUploadHandler}" mode="advanced" rendered="#{zapCtrl.hasDomaci}" />
                                <p:commandButton value="Snimi" actionListener="#{zapCtrl.snimiDomaci}" ajax="false" rendered="#{zapCtrl.hasDomaci}"/>
                            </h:panelGrid> 
                        </p:tab>
                    </p:tabView>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

